﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Memorandum
{
   public class AutoStart
    {
        public void SetAutoStart()
        {
           // string path = Application.ExecutablePath;
            string path = Process.GetCurrentProcess().MainModule.FileName;
            RegistryKey rk = Registry.LocalMachine;
            RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            rk2.SetValue("JcShutdown", path);
            rk2.Close();
            rk.Close();
        }
        public void CloseAutoStart()
        {
            string path = Process.GetCurrentProcess().MainModule.FileName;
            RegistryKey rk = Registry.LocalMachine;
            RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            rk2.DeleteValue("JcShutdown", false);
            rk2.Close();
            rk.Close();
        }
           
             
    }
}
